package com.bob.usercenter.handler;


import com.bob.usercenter.common.Result;
import com.bob.usercenter.exception.BusinessException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class MyExceptionHandler {
    //捕获自定义异常
    @ExceptionHandler(value = BusinessException.class)
    public Result CustomerExceptionHandler(BusinessException e){
         log.error("业务层面异常！原因是:"+e.getErrorCode().getDescription());
        return Result.error(e.getErrorCode());
    }
 }
